
<%@ page language="java" %>

<%@ page import="java.util.List,
                java.util.ArrayList,
                java.util.Iterator,
                com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm,
                com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/packingSlipMenu.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<html:html locale="true">


<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<SCRIPT language="JavaScript">

function selectPackingSlip() {
    if (document.packingSlipMenuForm.customerShippingId.value != -3) {
        document.packingSlipMenuForm.action="<%=chipTracContext%>/packingSlipMenu.do?action=view&customerShippingId=" + document.packingSlipMenuForm.customerShippingId.value;
        document.packingSlipMenuForm.submit();
    }
}

function viewCancelledPackingSlip() {
    if (document.packingSlipMenuForm.cancelledCustomerShippingId.value != -1) {
        var packingSlipViewURL = '<%=chipTracContext%>/packingSlip.do?action=printView&customerShippingId=' + document.packingSlipMenuForm.cancelledCustomerShippingId.value;
        newWindow = window.open (packingSlipViewURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
        newWindow.focus();
    }
}

function viewConfirmedPackingSlip() {
    if (document.packingSlipMenuForm.confirmedCustomerShippingId.value != -1) {
        var packingSlipViewURL = '<%=chipTracContext%>/packingSlip.do?action=printView&customerShippingId=' + document.packingSlipMenuForm.confirmedCustomerShippingId.value;
        newWindow = window.open (packingSlipViewURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
        newWindow.focus();
    }
}

function viewCancelledPackingSlip1() {
    if (document.packingSlipMenuForm.cancelledCustomerShippingId1.value != -1) {
        var packingSlipViewURL = '<%=chipTracContext%>/packingSlip.do?action=printView&customerShippingId=' + document.packingSlipMenuForm.cancelledCustomerShippingId1.value;
        newWindow = window.open (packingSlipViewURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
        newWindow.focus();
    }
}

function viewConfirmedPackingSlip1() {
    if (document.packingSlipMenuForm.confirmedCustomerShippingId1.value != -1) {
        var packingSlipViewURL = '<%=chipTracContext%>/packingSlip.do?action=printView&customerShippingId=' + document.packingSlipMenuForm.confirmedCustomerShippingId1.value;
        newWindow = window.open (packingSlipViewURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
        newWindow.focus();
    }
}

function selectCancelledPackingSlip() {
    document.packingSlipMenuForm.action = "<%=chipTracContext%>/packingSlipMenu.do?action=view&customerShippingId=" + document.packingSlipMenuForm.cancelledCustomerShippingId.value;
    document.packingSlipMenuForm.submit();
}

function selectPackingSlip1() {
    if (document.packingSlipMenuForm.customerShippingId1.value != -1) {
        document.packingSlipMenuForm.action="<%=chipTracContext%>/packingSlipMenu.do?action=view&customerShippingId=" + document.packingSlipMenuForm.customerShippingId1.value;
        document.packingSlipMenuForm.submit();
    }
}

function loadPackingSlips() {
    if (document.packingSlipMenuForm.salesOrderId.value != -1) {
        formAction = "<%=chipTracContext%>/packingSlipMenu.do?action=loadPackingSlips&salesOrderId=" + document.packingSlipMenuForm.salesOrderId.value;
        document.packingSlipMenuForm.action=formAction;
        document.packingSlipMenuForm.submit();
    }
}
</SCRIPT>


<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@include file="/jsp/operations/operations_menu.jsp" %>
<!-- end of the side navigations -->


<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>


<!-- body starts -->

<center><span class="NArialW">Packing Slip Menu</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>

<html:form name="packingSlipMenuForm" type="com.scalar.chiptrack.ChipTrackActionForm" action="/packingSlipMenu.do?action=view">

   <table border='0' width='60%' align='center'>

        <tr><td><chiptrack:info styleClass='NArialL'/></td></tr>
        <tr><td><chiptrack:errors styleClass='NArialL'/></td></tr>

        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

        <tr><td bgcolor='#993333'><font class="NArialL"><font color='#FFFFFF'>Packing Slips (Issued)</font></font></td></tr>
        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=4></td></tr>
        <tr><td valign='center'  nowrap bgcolor='#DEE1E2'><font class="NArialL">Create or View Packing Slip: </font>&nbsp;
            <select name="customerShippingId">
            <option value="-1">-- Generate New Packing Slip --</option>
            <!--option value="-3">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</option-->
            <!--option value="-2"> Generate New Packing Slip </option -->
            <option value="-3">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</option>
            <%
                ArrayList packingSlipList = (ArrayList) session.getAttribute ("packingSlipList");
                if (packingSlipList == null) packingSlipList = new ArrayList();
                int packingSlipListSize = packingSlipList.size();

                PackingSlipForm packingSlip = null;
                String label = null;

                for (int i=0; i<packingSlipListSize; i++) {
                    packingSlip = (PackingSlipForm) packingSlipList.get (i);
                    label = packingSlip.getLabel();

                    out.print ("<option value='" + packingSlip.getCustomerShippingId() + "'> View --> " + label);
                }
            %>
            </select>

        &nbsp;&nbsp;<a href="javascript:selectPackingSlip();" onMouseOver="window.status='Click here to view the packing slip';return true" onMouseOut="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif"></a>
        </td></tr>


        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td></tr>
        <tr><td bgcolor='#993333'><font class="NArialL"><font color='#FFFFFF'>Packing Slips (Shipped)</font></font></td></tr>
        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=4></td></tr>
        <tr><td  nowrap valign='center' bgcolor='#DEE1E2'><font class="NArialL">All Confirmed Packing Slips: </font>&nbsp;
            <select name="confirmedCustomerShippingId">
            <option value="-1">--Select Packing Slip to View--</option>
            <option value="-1">- - - - - - - - - - - - - - - - - - - - -</option>
            <%
                ArrayList confirmedPackingSlipList = (ArrayList) session.getAttribute ("confirmedPackingSlipList");
                if (confirmedPackingSlipList == null) confirmedPackingSlipList = new ArrayList();
                int confirmedPackingSlipListSize = confirmedPackingSlipList.size();

                PackingSlipForm confirmedPackingSlip = null;
                label = null;

                for (int i=0; i<confirmedPackingSlipListSize; i++) {
                    confirmedPackingSlip = (PackingSlipForm) confirmedPackingSlipList.get (i);
                    label = confirmedPackingSlip.getLabel();

                    out.print ("<option value='" + confirmedPackingSlip.getCustomerShippingId() + "'> " + label);
                }
            %>
            </select>

        &nbsp;&nbsp;<a href="javascript:viewConfirmedPackingSlip();" onMouseOver="window.status='Click here to view the Shipped packing slip';return true" onMouseOut="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif"></a>
        </td></tr>




        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td></tr>
        <tr><td bgcolor='#993333'><font class="NArialL"><font color='#FFFFFF'>Packing Slips (Cancelled)</font></font></td></tr>
        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=4></td></tr>
        <tr><td nowrap valign='center' bgcolor='#DEE1E2'><font class="NArialL">All Cancelled Packing Slips: </font>&nbsp;
            <select name="cancelledCustomerShippingId">
            <option value="-1">--Select Packing Slip to View--</option>
            <option value="-1">- - - - - - - - - - - - - - - - - - - - -</option>
            <%
                ArrayList cancelledPackingSlipList = (ArrayList) session.getAttribute ("cancelledPackingSlipList");
                if (cancelledPackingSlipList == null) cancelledPackingSlipList = new ArrayList();
                int cancelledPackingSlipListSize = cancelledPackingSlipList.size();

                PackingSlipForm cancelledPackingSlip = null;
                label = null;

                for (int i=0; i<cancelledPackingSlipListSize; i++) {
                    cancelledPackingSlip = (PackingSlipForm) cancelledPackingSlipList.get (i);
                    label = cancelledPackingSlip.getLabel();

                    out.print ("<option value='" + cancelledPackingSlip.getCustomerShippingId() + "'> " + label);
                }
            %>
            </select>

        &nbsp;&nbsp;<a href="javascript:viewCancelledPackingSlip();" onMouseOver="window.status='Click here to view the cancelled packing slip';return true" onMouseOut="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif"></a>
        </td></tr>

        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td></tr>
        <tr><td bgcolor='#993333'><font class="NArialL"><font color='#FFFFFF'>View Packingslips by Customer Purchase Order No</font></font></td></tr>
        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=4></td></tr>
            <%
                List salesOrderIds = (List) session.getAttribute ("salesOrderIds");
                if (salesOrderIds == null) salesOrderIds = new ArrayList();
                int salesOrderIdsSize = salesOrderIds.size();
                
                if (salesOrderIdsSize > 0) {
            %>

            <tr><td valign='center' bgcolor='#DEE1E2'><font class="NArialL">Select Packing Slips By Customer PO's:</font>&nbsp;
            <select name="salesOrderId" onchange="loadPackingSlips ('salesOrderId')">
            <option value="-1">-- Select customer PO --</option>
            <option value="-1">- - - - - - - - - - - - - - - - - - - - -</option>
            <%
                    String[] ids = null;

                    for (int i=0; i<salesOrderIdsSize; i++) {
                        ids = (String[]) salesOrderIds.get(i);
                        out.print ("<option value=" + ids[0]);

                        if (ids[0].equalsIgnoreCase ((String) request.getAttribute("salesOrderId"))) {
                            out.print (" selected ");
                        }
                        out.println (" > " + ids[1]);
                    }
            %>
            </select>

            <ul>
            <%
                    // SHOW ALL PACKINGSLIPS CREATED FOR THIS CUSTOMER PO
            
                    ArrayList packingSlipListBySalesOrderId = (ArrayList) request.getAttribute ("packingSlipListBySalesOrderId");
                    if (packingSlipListBySalesOrderId == null) packingSlipListBySalesOrderId = new ArrayList();
                    int packingSlipListBySalesOrderIdSize = packingSlipListBySalesOrderId.size();
                    if (packingSlipListBySalesOrderIdSize > 0) {
            %>
                        <li><p><font class='NArialL'>&nbsp;&nbsp;&nbsp;&nbsp;All Issued Packing Slips:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>
                        <select name="customerShippingId1">
                        <option value='-1'>-- Select Package Slip --</option>
                        <option value='-1'>----------------------------------</option>
            <%
                            packingSlip = null;
                            label = null;

                            for (int i=0; i<packingSlipListBySalesOrderIdSize; i++) {
                                packingSlip = (PackingSlipForm) packingSlipListBySalesOrderId.get (i);
                                label = packingSlip.getLabel();

                                out.print ("<option value='" + packingSlip.getCustomerShippingId() + "'> " + label);
                            }
            %>
                            <input type="hidden" name="packingSlipSalesOrderId" value='<%=packingSlip.getSalesOrderId()%>'>
                        </select>&nbsp;&nbsp;
                        <a href="javascript:selectPackingSlip1();" onMouseOver="window.status='Click here to view the packing slip';return true" onMouseOut="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif"></a>
            <%
                        } // if (packingSlipListBySalesOrderIdSize > 0) 

                        else if (request.getAttribute("salesOrderId") != null) {
            %>
                            <li><p><font class='NArialL'><font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;No Issued packingslips found for this Customer PO</font></font>
            <%
                        }
            

                    // SHOW ALL CONFIRMED PACKING SLIPS FOR THIS CUSTOMER PO

                    ArrayList confirmedPackingSlipListBySalesOrderId = (ArrayList) request.getAttribute ("confirmedPackingSlipListBySalesOrderId");
                    if (confirmedPackingSlipListBySalesOrderId == null) confirmedPackingSlipListBySalesOrderId = new ArrayList();
                    int confirmedPackingSlipListBySalesOrderIdSize = confirmedPackingSlipListBySalesOrderId.size();
                    if (confirmedPackingSlipListBySalesOrderIdSize > 0) {
            %>
                        <li><p><p><font class='NArialL'>&nbsp;&nbsp;&nbsp;&nbsp;Confirmed Packing Slips:</font>
                        <select name="confirmedCustomerShippingId1">
                        <option value='-1'>-- Select Package Slip to view --</option>
                        <option value='-1'>----------------------------------</option>
            <%
                            packingSlip = null;
                            label = null;

                            for (int i=0; i<confirmedPackingSlipListBySalesOrderIdSize; i++) {
                                packingSlip = (PackingSlipForm) confirmedPackingSlipListBySalesOrderId.get (i);
                                label = packingSlip.getLabel();

                                out.print ("<option value='" + packingSlip.getCustomerShippingId() + "'> " + label);
                            }
            %>
                            <input type="hidden" name="packingSlipSalesOrderId" value='<%=packingSlip.getSalesOrderId()%>'>
                        </select>&nbsp;&nbsp;
                        <a href="javascript:viewConfirmedPackingSlip1();" onMouseOver="window.status='Click here to view the confirmed packing slip';return true" onMouseOut="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif"></a>
            <%
                        } // if (confirmedPackingSlipListBySalesOrderIdSize > 0)


                    // SHOW ALL CANCELLED PACKING SLIPS FOR THIS CUSTOMER PO

                    ArrayList cancelledPackingSlipListBySalesOrderId = (ArrayList) request.getAttribute ("cancelledPackingSlipListBySalesOrderId");
                    if (cancelledPackingSlipListBySalesOrderId == null) cancelledPackingSlipListBySalesOrderId = new ArrayList();
                    int cancelledPackingSlipListBySalesOrderIdSize = cancelledPackingSlipListBySalesOrderId.size();
                    if (cancelledPackingSlipListBySalesOrderIdSize > 0) {
            %>
                        <li><p><p><font class='NArialL'>&nbsp;&nbsp;&nbsp;&nbsp;Cancelled Packing Slips:</font>
                        <select name="cancelledCustomerShippingId1">
                        <option value='-1'>-- Select Package Slip to view --</option>
                        <option value='-1'>----------------------------------</option>
            <%
                            packingSlip = null;
                            label = null;

                            for (int i=0; i<cancelledPackingSlipListBySalesOrderIdSize; i++) {
                                packingSlip = (PackingSlipForm) cancelledPackingSlipListBySalesOrderId.get (i);
                                label = packingSlip.getLabel();

                                out.print ("<option value='" + packingSlip.getCustomerShippingId() + "'> " + label);
                            }
            %>
                            <input type="hidden" name="packingSlipSalesOrderId" value='<%=packingSlip.getSalesOrderId()%>'>
                        </select>&nbsp;&nbsp;
                        <a href="javascript:viewCancelledPackingSlip1();" onMouseOver="window.status='Click here to view the cancelled packing slip';return true" onMouseOut="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif"></a>
            <%
                        } // if (cancelledPackingSlipListBySalesOrderIdSize > 0)
            %>
                </ul>
                        </td></tr>

            <%
                }   //if (salesOrderIdsSize > 0) {
            %>
    </table>

</html:form>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</body>

</html:html>